﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using TFXK.BLL;
using TFXK.Common;
using log4net;
using TFXK.Model;

public partial class GNMainPage : System.Web.UI.MasterPage
{
    private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    private static readonly CategoryBLL bllCategory = new CategoryBLL();
    private static readonly NewsBLL bllNews = new NewsBLL();
    private static readonly LinkBLL bllLink = new LinkBLL();
    private static readonly TravelLinesBLL bllTravelLines = new TravelLinesBLL();
    int rowCount = 0;
    public string Keywords;
    public string Description;
    public string Hlable;

    public TravelLines modelTemp = new TravelLines();
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                SetMeta();
                BindCityLable();
                BindHelp();
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }

    //旅游资讯
    public void BindHelp()
    {
        this.rptTravelHelp.DataSource = bllNews.GetListByShowType(15, 1, 1, out rowCount);
        rptTravelHelp.DataBind();

    }

    //导航文字
    public void BindCityLable()
    {
        string MapPic = string.Empty;
        //展示内容 周边 沙漠
        if (Request.QueryString["ShowType"] != null)
        {
            try
            {

                string showTypeCode = StringUtil.HtmlEncode(Request.QueryString["ShowType"] + "");
                if (showTypeCode.Equals("zbly"))
                {
                    lblCity.Text = "周边旅游";
                }
                else
                {
                    if (!string.IsNullOrEmpty(showTypeCode))
                    {
                        lblCity.Text = bllCategory.GetModel(showTypeCode).title;
                    }
                }
            }
            catch
            {
            }
        }
        else
        {
        }
        if (!string.IsNullOrEmpty(Request.QueryString["PID"] + ""))
        {

            int key = int.Parse(Request.QueryString["PID"] + "");
            if (key > 0)
            {
                try
                {
                    lblCity.Text = bllCategory.GetModel(key).title;
                }
                catch { }
            }
        }
        else
        {
            if (!string.IsNullOrEmpty(Request.QueryString["Key"] + ""))
            {
                try
                {
                    int cityid = bllTravelLines.GetModel(int.Parse(Request.QueryString["Key"] + "")).endCity.Value;
                    Category tempModel = bllCategory.GetModel(bllCategory.GetModel(cityid).parentID);
                    lblCity.Text = tempModel.title;

                    bool isCJ = false;
                    switch (lblCity.Text)
                    {
                        case "美洲旅游":
                            isCJ = true;
                            break;
                        case "欧洲旅游":
                            isCJ = true;
                            break;
                        case "澳洲旅游":
                            isCJ = true;
                            break;
                        case "中东非洲旅游":
                            isCJ = true;
                            break;
                        case "日韩旅游":
                            isCJ = true;
                            break;
                        case "东南亚旅游":
                            isCJ = true;
                            break;
                        case "越南柬埔寨":
                            isCJ = true;
                            break;
                        case "马尔代夫":
                            isCJ = true;
                            break;
                        case "印度尼泊尔":
                            isCJ = true;
                            break;
                    }
                    if (isCJ)
                    {
                        Response.Redirect("CJ_TravelInfo.aspx?Key=" + Request.QueryString["Key"], false);
                    }
                }
                catch { }
            }
        }

        XLTJControl1.TravelTypeCode = "gnly";
        switch (lblCity.Text)
        {
            case "三亚":
                MapPic = "gnsanya.jpg";
                break;
            case "云南":
                MapPic = "gnyunnan.jpg";
                break;
            case "北京":
                MapPic = "gnbeijing.jpg";
                break;
            case "广西":
                MapPic = "gnguangxi.jpg";
                break;
            case "四川":
                MapPic = "gnsichuan.jpg";
                break;
            case "福建":
                MapPic = "gnfujian.jpg";
                break;
            case "湖南":
                MapPic = "gnhunan.jpg";
                break;
            case "华东苏杭":
                MapPic = "gnsuhang.jpg";
                break;
            case "大连青岛":
                MapPic = "gndalianqingdao.jpg";
                break;
            case "西部":
                MapPic = "gnxibu.jpg";
                break;
            case "贵州":
                MapPic = "gnguizhou.jpg";
                break;

            case "香港澳门":
                MapPic = "gngangao.jpg";
                break;
            case "台湾":
                MapPic = "gntaiwan.jpg";
                break;
            default:
                MapPic = "";
                break;
        }
        XLTJControl1.MapImgUrl = MapPic;
    }

    public void SetMeta()
    {
        if (Request.QueryString["Key"] != null)
        {
            int Key = Int32.Parse(Request.QueryString["Key"].ToString());

            modelTemp = bllTravelLines.GetModel(Key);

            this.Keywords = "\"" + modelTemp.title + "\"";
            this.Description = "\"" + modelTemp.featureDes.Substring(0, 100) + "\"";
            this.Hlable = modelTemp.title;
        }
        else
        {
            this.Keywords = "\"国内旅游景点,成都到海南三亚旅游线路,国内旅游景点推荐,国内旅游景点介绍,国内旅游路线,国内旅游网,国内旅行社,国内旅游胜地,国内旅游报价,国内热门旅游路线\"";
            this.Description = "\"下驿栈旅游网国内旅游频道为您提供最准确实用的国内旅游信息,包括国内热门的旅游路线,国内旅游报价,成都到海南三亚旅游,成都到云南旅游,成都到厦门旅游,国内旅游景点推荐等国内旅行资讯与咨询服务\"";
            this.Hlable = "国内旅游线路推荐,海南三亚旅游,云南旅游,厦门旅游,台湾旅游,广西旅游,国内旅游景点报价";
        }

    }

}
